﻿using B.S.Data.MES.API.Applications.QualityManagement.ExamineDesignCommand.Commands;
using B.S.Domain.BasicData.QualityManagement;
using B.S.Infratrctrue;
using B.S.Requst;
using MediatR;

namespace B.S.Data.MES.API.Applications.QualityManagement.ExamineDesignCommand.CommandHandlers
{
    public class UpdateExamineDesignCommandHandler : IRequestHandler<UpdateExamineDesignCommand, APIRequst<int>>
    {
        private readonly IBaseRepository<ExamineDesign> _examinedesignRepository;
        public UpdateExamineDesignCommandHandler(IBaseRepository<ExamineDesign> examinedesignRepository)
        {
            _examinedesignRepository = examinedesignRepository;
        }
        public Task<APIRequst<int>> Handle(UpdateExamineDesignCommand request, CancellationToken cancellationToken)
        {
            ExamineDesign design = new ExamineDesign();
            design.DesignId = request.DesignId;
            design.DesignName = request.DesignName;
            design.DesugbType = request.DesugbType;
            design.InspectionMethod = request.InspectionMethod;
            design.DesignValue = request.DesignValue;
            design.ExamineProjectName = request.ExamineProjectName;
            design.DesignDescription = request.DesignDescription;
             _examinedesignRepository.Update(design);

            return Task.FromResult(new APIRequst<int>
            {
                Code = RequstCode.成功,
                Msg = RequstCode.成功.ToString()
            });
        }
    }
}
